//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.datafactory.Team.controller;

import com.datafactory.Team.common.Result;
import com.datafactory.Team.entity.Params;
import com.datafactory.Team.entity.Team;
import com.datafactory.Team.entity.TeamType;
import com.datafactory.Team.service.TeamService;
import com.github.pagehelper.PageInfo;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin(
        origins = {"*"}
)
@RestController
@RequestMapping({"/data_factory/team_details"})
public class TeamController {
    @Resource
    private TeamService teamService;

    public TeamController() throws UnsupportedEncodingException {
    }

    @GetMapping
    public Result findBySearch(Params params) {
        PageInfo<Team> info = this.teamService.findBySearch(params);
        return Result.success2(info);
    }

    @GetMapping({"/team_type"})
    public Result findBySearchType(Params params) {
        PageInfo<TeamType> info = this.teamService.findBySearchType(params);
        return Result.success2(info);
    }
    @GetMapping({"/finddetail/{team_id}"})
    public Result findById(@PathVariable Integer team_id) {
        List<Team> list = this.teamService.findById(team_id);
        return Result.success2(list);
    }
    @GetMapping({"/type_finddetail/{team_typeid}"})
    public Result findByTypeId(@PathVariable Integer team_typeid) {
        List<TeamType> list = this.teamService.findByTypeId(team_typeid);
        return Result.success2(list);
    }

    @DeleteMapping({"/delete/{id}"})
    public Result delete(@PathVariable Integer id) {
        this.teamService.delete(id);
        return Result.success1();
    }
    @DeleteMapping({"/type_delete/{id}"})
    public Result deleteTeamtype(@PathVariable Integer id) {
        this.teamService.deleteTeamtype(id);
        return Result.success1();
    }

    @PostMapping({"/add"})
    public Result save(@RequestBody Team team) {
        this.teamService.add(team);
        return Result.success1();
    }
    @PostMapping({"/type_add"})
    public Result saveType(@RequestBody TeamType team) {
        this.teamService.Typeadd(team);
        return Result.success1();
    }
    @PostMapping({"/update"})
    public Result update(@RequestBody Team team) {
        this.teamService.update(team);
        return Result.success1();
    }
    @PostMapping({"/type_update"})
    public Result updateType(@RequestBody TeamType teamtype) {
        this.teamService.updateType(teamtype);
        return Result.success1();
    }

}
